(function flexible (window, document) {
  var docEl = document.documentElement;
  function setFontSize () {
    var width = docEl.clientWidth;
    docEl.style.fontSize = (width / 12.8).toFixed(2) + 'px';
  }
  setFontSize();
  // reset rem unit on page resize
  window.addEventListener('resize', function () {
    setFontSize();
    /* 记录页面窗口的变化 */
    sessionStorage.viewResize = sessionStorage.viewResize || 0;
    sessionStorage.viewResize = Number(sessionStorage.viewResize) + 1;
  });
  window.addEventListener('pageshow', function (e) {
    if (e.persisted) {
      setFontSize();
    }
  });
}(window, document));
